function validate(loginname,password,confirm,vnum,firstnum,secondnum){
  let errors = "";
  if(!(/^[\u4e00-\u9fa5A-Za-z0-9-_]{3,10}$/.test(loginname))){
    errors = errors || {};
    errors.loginname = "用户名只能使用中英文，数字，下划线，减号，长度在3~10之间。";
  }
  if(!(/^[a-zA-Z]\w{5,11}$/.test(password))){
    errors = errors || {};
    errors.password = "密码应以字母开头，只能包含字符、数字和下划线，长度在6-12之间。";
  }
  if(!(confirm === password)){
    errors = errors || {};
    errors.confirm = "两次输入密码不同，请重新输入。";
  }
  if(!(Number(vnum) === firstnum + secondnum)){
    errors = errors || {};
    errors.vnum = "验证码输入有误，请重新输入。";
  }
  console.log(errors);

  return errors;
}

function showInfo(errors){
  if(errors){
    // console.log(errors);
    // console.log(typeof errors);
    errors = JSON.parse(errors);
    if(errors.loginname){
      loginnameerror.innerText = errors.loginname;
    }
    if(errors.password){
      passworderror.innerText = errors.password;
    }
    if(errors.confirm){
      confirmerror.innerText = errors.confirm;
    }
    if(errors.content){
      contenterror.innerText = errors.content;
    }
    if(errors.vnum){
      vnumerror.innerText = errors.vnum;
    }
  }
}



if(typeof window === "undefined"){
  module.exports = validate;
}
